<!DOCTYPE html>
<html lang='zh-CN'>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>抽奖规则</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.min.css" rel="stylesheet">
    <link href="js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid p-t-15">
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header">
                    <div id="toolbar" class="toolbar-btn-action">
                        <form class="form-inline" method="post" id="searchForm">
                            <div class="form-group">
                                <button class="btn btn-success btn_query btn-round" type="button" id="addBtn">添加抽奖规则</button>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-warning btn_query btn-round" type="button" id="editBtn">编辑抽奖规则</button>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-purple btn_query btn-round" type="button" id="prizeBtn">中奖奖品</button>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-info btn_query btn-round" type="button" id="winBtn">中奖记录</button>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-cyan btn_query btn-round" type="button" id="recordBtn">抽奖记录</button>
                            </div>
                        </form>
                    </div>
                    <div class="card-body">
                        <table id="grid_data" class="table text-nowrap"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

    <!--  添加与编辑模态框 -->
    <div class="modal fade" id="addOrEditModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <span>添加/编辑</span>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <div id="error_tips" style="color: #c9302c"></div>
                </div>
                <div class="modal-body">
                    <form id="addOrEditForm" method="post">
                        <div class="row">
                            <div class="col-xs-12">
                                <div class="input-group m-b-10">
                                    <span class="input-group-addon">每次抽奖耗费多少金币</span>
                                    <input type="hidden" name="id">
                                    <input type="text" name="ruleFee" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^[0]+[0-9]*$/gi,'')">
                                </div>
                            </div>
                            <div class="col-xs-12">
                                <div class="input-group m-b-10">
                                    <span class="input-group-addon">每个人抽奖次数</span>
                                    <input type="text" name="ruleCount" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^[1]+[0-9]*$/gi,'')">
                                </div>
                            </div>
                            <div class="col-xs-12">
                                <div class="input-group m-b-10">
                                    <span class="input-group-addon">中奖的基数</span>
                                    <input type="text" name="ruleBase" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^[0]+[0-9]*$/gi,'')">
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary addSaveBtn" id="saveBtn">保存</button>
                        </div>
                    </form>
                </div>

            </div>
        </div>
    </div>

    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/bootstrap-table/bootstrap-table.js"></script>
    <script type="text/javascript" src="js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
    <script type="text/javascript" src="js/zero2one/zero2one.version.js"></script>
    <script type="text/javascript" src="js/zero2one/zero2one.core.js"></script>
    <!-- bootstrap表单验证插件 -->
    <script type="text/javascript" src="js/bootstrapvalidator/dist/js/bootstrapValidator.js"></script>
    <!-- bootstrap弹出框插件 -->
    <script type="text/javascript" src="js/jquery.bootstrap.min.js"></script>
    <!-- 表单填充插件 -->
    <script type="text/javascript" src="js/jquery-form/jquery.formloader.js"></script>
    <script type="text/javascript" src="js/zero2one/zero2one.curd.js"></script>
    <script type="text/javascript">
        //设置表头
        var columns = [
            {checkbox: true},
            {field: 'id',title: '编号'},
            {field: 'ruleFee',title: '每次抽奖耗费多少金币'},
            {field: 'ruleCount',title: '每个人抽奖次数'},
            {field: 'ruleBase',title: '中奖的基数'}
         ];

        //加载列表信息
        zero2one.table("/remote/prizeRule/list", columns);

        //点击添加弹出模态框
        zero2one.addModal();

        //点击编辑按钮弹出模态框
        zero2one.editModal();

        //点击保存按钮提交请求且提交前先执行表单验证
        $('#addOrEditForm').bootstrapValidator({
            fields: {
                ruleFee: {validators: {notEmpty: {message: '抽奖金币不能为空'}}},
                ruleCunt: {validators: {notEmpty: {message: '抽奖次数不能为空'}}}
            }
        });
        zero2one.save("/remote/prizeRule/addOrEdit");

        //查看抽奖记录
        $("#recordBtn").click(function () {
            zero2one.tab("抽奖记录","/toView?url=service/market/prizeRecord");
        });

        //中奖奖品操作
        $("#prizeBtn").click(function () {
            zero2one.tab("中奖奖品","/toView?url=service/market/prizeInfo");
        });

        //查看中奖记录
        $("#winBtn").click(function () {
            zero2one.tab("中奖记录","/toView?url=service/market/prizeWin");
        });

    </script>
</div>
</body>
</html>
